<?php

namespace SummoIngenio\Sai\MatematicaBundle\Utility\Juego\P0;
use SummoIngenio\Sai\MatematicaBundle\Utility\Juego\JuegoBase;
define('CANT_PROBLEMAS', 5);
/**
 * Description of P01036
 *
 * @author SVM
 */

class P01036 extends JuegoBase {
  
  public function init() {
   $base1 = rand(1,1);
   $base2 = rand(0,1);
   $billete5 = 0;
   $monedas = 0;
   $billete10 = $base1;
   if($base1 == 1){
		if($base2==1){
			$billete5 = rand(1,2);
			if($billete5==1){
				$monedas = rand(1,5);
			}
			if($billete5==2){
				$monedas = 0;
			}			
		}else{
			$monedas = rand(1,10);
	   }		
   }else{
	   if($base2==1){
			$billete5 = rand(1,4);
		   if($billete5<4){
				$monedas = rand(1,(20-5*$billete5));
		   }else{
		        $monedas = 0;
		   }	
	   }else{
			$monedas = rand(10,20);
	   }
   }
   $this->monedas = $monedas;
   $this->billete5 = $billete5;
   $this->billete10 = $billete10;
  }
  
  public function getPregunta() {
    return '';
  }
  public function getHtmlDesactivado() {	
    return $this->render('P0/P01036/desactivado', array(
        'monedas'   =>  $this->monedas,		
        'billete5'   =>  $this->billete5,
        'billete10'   =>  $this->billete10,		
      ));
  }
  
  public function getHtmlJugable() {
    return $this->render('P0/P01036/jugable', array(
        'monedas'   =>  $this->monedas,		
        'billete5'   =>  $this->billete5,
        'billete10'   =>  $this->billete10,				
      ));
  }
  
  public function getHtmlResuelto() {
    return $this->render('P0/P01036/resuelto', array(
        'monedas'   =>  $this->monedas,		
        'billete5'   =>  $this->billete5,
        'billete10'   =>  $this->billete10,		
      ));
  }
  
  public function verificarRespuesta($respuestaUsuario) {
     $rsp = true;
	 $cadena = "10*"+$this->billete10+"+5*"+$this->billete5+"1*"+$this->monedas;
	 if($respuestaUsuario->get('valor1')!=(10*$this->billete10+5*$this->billete5+$this->monedas)){ 
	   $rsp=false;
	 } 
    $aRetornar = array(
      'respuesta' => $cadena,
      'correcta'  => $rsp,
    );
    return $aRetornar;
  }

  public function getJavascript() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01036.js"
    );
    return $aRetornar;
  }

  public function getCss() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01036.css"
    );
    return $aRetornar;
  }

  public function __sleep() {
    return array(
        'monedas',
        'billete5',		
        'billete10',	
    );
  }
}

?>